import logging

def get_logger(kwargs, default_name):
    """
    Set up the logger and return it:
        if 'logger_name' is in kwargs use it and remove it, otherwise
        just use the default name.
    Inputs:
            kwargs      : a list of keyword arguments with or without 'logger_name' in it
            default_name: a default name for this logger
    Returns:
            logger      : the logger object you can use to log with
            logger_name : the name of this logger, so you can pass it deeper into your codes
    """
    if 'logger_name' in kwargs.keys() and kwargs['logger_name'] is not None:
        parts  = default_name.split('.')
        suffix = parts[-1]
        logger_name = kwargs['logger_name']+'.'+suffix
        logger = logging.getLogger(logger_name)
        del kwargs['logger_name']
    else:
        logger_name = default_name
        logger = logging.getLogger(logger_name)
    return logger, logger_name
    
